package com.example.bookmanage.service.impl;

import cn.hutool.core.lang.UUID;
import com.example.bookmanage.constants.JwtConstants;
import com.example.bookmanage.utils.JwtUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
@Slf4j
public class TokenService {

    public String createToken(Long userId, String secret, Integer identity, String nickName) {


        Map<String, Object> claims = new HashMap<>();
        String userKey = UUID.fastUUID().toString(true).replace("-", "");
        claims.put(JwtConstants.LOGIN_USER_ID, userId);
        claims.put(JwtConstants.LOGIN_TOKEN_KEY, userKey);

        return JwtUtils.createToken(claims, secret);

    }

}
